#include <malloc.h>
#include "08_lib.h"
queuep InitQueue(void)
{
	queuep q = (queuep)malloc(sizeof(queue));
	SetEmpty(q);
	return q;
}
int IsEmpty(queuep q)
{
	return (q->front == q->rear) ? 1 : 0;
}
void SetEmpty(queuep q)
{
	q->front = 0;
	q->rear = 0;
}
int IsFull(queuep q)
{
	return (((q->rear + 1) % MAX_SIZE) == q->front) ? 1 : 0;
}
void PushQueue(queuep q,int v)
{
	if(IsFull(q) == 1)
	{
		return;
	}
	q->data[q->rear] = v;
	q->rear = (q->rear + 1) % MAX_SIZE;
}
int OutQueue(queuep q)
{
	if(IsEmpty(q) == 1)
	{
		return -1;
	}
	int temp = q->data[q->front];
	q->front = (q->front + 1) % MAX_SIZE;
	return temp;
}
int ShowFront(queuep q)
{
	if(IsEmpty(q) == 1)
	{
		return -1;
	}
	return q->data[q->front];
}
